package cc;

abstract class Animal {  
    // 返回动物的叫声  
    public abstract String cry();  
      
    // 返回动物的种类名称  
    public abstract String getAnimalName();  
}  
   
class Dog extends Animal {   
    public String cry() { return "汪汪汪"; }   
    public String getAnimalName() { return "狗"; }  
}  
    
class Cat extends Animal {  
    public String cry() { return "喵喵喵"; }    
    public String getAnimalName() { return "猫"; }  
}  
    
class Simulator {   
    public void playSound(Animal animal) {  
        System.out.println("动物种类: " + animal.getAnimalName());  
        System.out.println("叫声: " + animal.cry());   
    }  
}  
   
public class Application {  
    public static void main(String[] args) {  
        // 创建模拟器对象  
        Simulator simulator = new Simulator();       
        // 播放狗的声音  
        simulator.playSound(new Dog());    
        // 播放猫的声音  
        simulator.playSound(new Cat());  
    }  
}
